import 'package:fluttertoast/fluttertoast.dart';
import 'package:permission_handler/permission_handler.dart';

class PermissionsHelper {
  static Future<bool> requestPermission(List<Permission> permissions) async {
    final status = await permissions.request();
    bool isAllGranted = true;
    bool showTip = false;
    status.forEach((key, value) {
      if (value.isDenied || value.isPermanentlyDenied) {
        isAllGranted = false;
      }
      if (value.isPermanentlyDenied) {
        showTip = true;
      }
    });
    if (showTip) {
      Fluttertoast.showToast(msg: '报错了');
    }
    return isAllGranted;
  }
}
